<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>山东旅游网</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css">
    <link rel="stylesheet" href="styles.css">
</head>

<body>
    <header>
        <div class="logo">山东旅游网</div>
        <div class="user-actions">
            <a href="register.jsp">注册</a>
            <a href="index.jsp">登录</a>
        </div>
    </header>
    <main>
        <div class="register-form">
            <h2>用户注册</h2>
            <p>${errorMsg}</p>
            <form action="registerdervlet" method="post" accept-charset="UTF-8">
                <label for="username">用户名：</label>
                <input type="text" id="username" name="username" placeholder="请输入用户名" required>
                <label for="email">邮箱：</label>
                <input type="email" id="email" name="email" placeholder="请输入正确邮箱格式" required>
                <label for="gender">性别：</label>
                <select id="gender" name="gender" required>
                    <option value="男">男</option>
                    <option value="女">女</option>
                </select>
                <label for="password">设置密码：</label>
                <input type="password" id="password" name="password" placeholder="请输入密码" required>
                <label for="confirm-password">再次设置密码：</label>
                <input type="password" id="confirm-password" placeholder="再次输入密码" required
                       oninput="checkPasswordMatch(this.value, document.getElementById('password').value)">
                <input type="submit" value="确定" class="submit-btn">
            </form>
        </div>
    </main>
    <footer>
        <div class="footer-container">
            <div class="footer-left">
                <div class="footer-logo">
                    <img src="./images/logo.png" alt="">
                </div>
                <div class="footer-text">
                    <p>
                        <span>Copyright © 2024</span>
                        <span>GuoYuJie</span>
                    </p>
                </div>
            </div>
        </div>
    </footer>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script>
    <script>
        $(document).ready(function() {
            // 检查是否有错误信息
            var errorMsg = "${errorMsg}";
            if (errorMsg) {
                alert(errorMsg); // 弹出提示框
            }

            // 表单提交验证
            $("form").submit(function(event) {
                var username = $("#username").val();
                if (username === "") {
                    alert("用户名不能为空，请输入用户名后再提交！");
                    event.preventDefault(); // 阻止表单提交
                }
            });
        });

        // 密码匹配检查
        function checkPasswordMatch(inputValue, passwordValue) {
            const submitBtn = document.querySelector('.submit-btn');
            if (inputValue === passwordValue) {
                submitBtn.disabled = false;
            } else {
                submitBtn.disabled = true;
            }
        }
    </script>
</body>

<style>
    /* 全局样式 */
    body {
        margin: 0;
        padding: 0;
        font-family: Arial, sans-serif;
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    /* 头部样式 */
    header {
        background-color: white;
        display: flex;
        justify-content: space-between;
        height: 60px;
        align-items: center;
        padding: 10px 20px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .logo {
        color: orange;
        font-size: 24px;
        font-weight: bold;
    }

    nav ul {
        list-style-type: none;
        margin: 0;
        padding: 0;
        display: flex;
    }

    nav ul li {
        margin-left: 20px;
    }

    nav ul li a {
        text-decoration: none;
        color: gray;
    }

    nav ul li a:hover {
        color: black;
    }

    .search-bar {
        display: flex;
        align-items: center;
    }

    .search-bar input {
        padding: 5px 10px;
        border: 1px solid gray;
        border-radius: 4px 0 0 4px;
    }

    .search-bar button {
        background-color: green;
        color: white;
        border: none;
        padding: 5px 10px;
        border-radius: 0 4px 4px 0;
        cursor: pointer;
    }

    .weather {
        display: flex;
        align-items: center;
    }

    .weather span {
        margin-right: 10px;
    }

    .user-actions a {
        margin-left: 20px;
        text-decoration: none;
        color: gray;
    }

    .user-actions a:hover {
        color: black;
    }

    /* footer样式 */
    footer {
        background-color: green;
        color: white;
        padding: 15px 0;
        width: 100%;
        height: 40px;
    }

    .footer-container {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .footer-left {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .footer-text {
        text-align: center;
    }

    /* 注册表单样式 */
    .register-form {
        width: 400px;
        margin: 80px auto;
        padding: 20px;
        border: 1px solid #ccc;
        border-radius: 5px;
        background-color: white;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }

    h2 {
        text-align: center;
        color: #333;
    }

    form label {
        display: block;
        margin-top: 10px;
        color: #555;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    select {
        width: 95%;
        padding: 10px;
        margin-top: 5px;
        border: 1px solid #ccc;
        border-radius: 3px;
    }

    .submit-btn {
        background-color: green;
        color: white;
        padding: 10px 20px;
        border: none;
        border-radius: 3px;
        cursor: pointer;
        margin-top: 15px;
    }
</style>
</html>